﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Net;

#endregion


namespace ESF.Peer.Configuration
{
	public class PeerInfoSection : ConfigurationSection
	{
		[ConfigurationProperty("name", IsRequired = true)]
        public string name
        {
            get
            { 
                return (string) this ["name"]; 
            }
            set
            { 
                this ["name"] = value; 
            }
        }
        
        
        [ConfigurationProperty("IPAddress", IsRequired = true)]
        public string IPAddress
        {
            get
            { 
                return (string) this ["IPAddress"]; 
            }
            set
            { 
                this ["IPAddress"] = value; 
            }
        }


		[ConfigurationProperty("masterServerIP", IsRequired = false)]
        public string MasterServerIP
        {
            get
            { 
                return (string) this ["masterServerIP"]; 
            }
            set
            { 
                this ["masterServerIP"] = value; 
            }
        }


		[ConfigurationProperty("masterServerPort", IsRequired = false)]
        public int MasterServerPort
        {
            get
            { 
                return (int) this ["masterServerPort"]; 
            }
            set
            { 
                this ["masterServerPort"] = value; 
            }
        }
        
        
        [ConfigurationProperty("port", IsRequired = false)]
        public int port
        {
            get
            { 
                return (int) this ["port"]; 
            }
            set
            { 
                this ["port"] = value; 
            }
        }


		[ConfigurationProperty("timerInterval", IsRequired = false)]
		public int timerInterval
        {
            get
            {
				return (int)this["timerInterval"]; 
            }
            set
            {
				this["timerInterval"] = value; 
            }
        }


		[ConfigurationProperty("sendTimeoutMS", IsRequired = false)]
        public int sendTimeoutMS
        {
            get
            { 
                return (int) this ["sendTimeoutMS"]; 
            }
            set
            { 
                this ["sendTimeoutMS"] = value; 
            }
        }


		[ConfigurationProperty("receiveTimeoutMS", IsRequired = false)]
        public int receiveTimeoutMS
        {
            get
            { 
                return (int) this ["receiveTimeoutMS"]; 
            }
            set
            { 
                this ["receiveTimeoutMS"] = value; 
            }
        }


		[ConfigurationProperty("receiveWaitTimeoutMS", IsRequired = false)]
		public int receiveWaitTimeoutMS
        {
            get
            {
				return (int)this["receiveWaitTimeoutMS"]; 
            }
            set
            {
				this["receiveWaitTimeoutMS"] = value; 
            }
        }
        
        
        [ConfigurationProperty("maxConnections", IsRequired = true)]
        public int maxConnections
        {
            get
            { 
                return (int) this ["maxConnections"]; 
            }
            set
            { 
                this ["maxConnections"] = value; 
            }
        }
        
        
        [ConfigurationProperty("noDelay", DefaultValue=false)]
        public bool noDelay
        {
            get
            { 
                return (bool) this ["noDelay"]; 
            }
            set
            { 
                this ["noDelay"] = value; 
            }
        }


		[ConfigurationProperty("allowUseOtherPort", DefaultValue=false)]
        public bool allowUseOtherPort
        {
            get
            { 
                return (bool) this ["allowUseOtherPort"]; 
            }
            set
            { 
                this ["allowUseOtherPort"] = value; 
            }
        }
        
        
        [ConfigurationProperty("peerType", IsRequired = false)]
        public string peerType
        {
            get
            { 
                return this ["peerType"] as string; 
            }
            set
            { 
                this ["peerType"] = value; 
            }
        }


		[ConfigurationProperty("allowedClients", IsRequired = false)]
		public string allowedClients
		{
			get
			{
				return this["allowedClients"] as string;
			}
			set
			{
				this["allowedClients"] = value;
			}
		}
        
        
        [ConfigurationProperty("readBufferLength", IsRequired = true)]
        public int readBufferLength
        {
            get
            { 
                return (int) this ["readBufferLength"]; 
            }
            set
            { 
                this ["readBufferLength"] = value; 
            }
        }


		[ConfigurationProperty("maxFileSendSizeMB", IsRequired = false)]
		public int maxFileSendSizeMB
		{
			get
			{
				return (int)this["maxFileSendSizeMB"];
			}
			set
			{
				this["maxFileSendSizeMB"] = value;
			}
		}


		[ConfigurationProperty("maxFileReceiveSizeMB", IsRequired = false)]
		public int maxFileReceiveSizeMB
		{
			get
			{
				return (int)this["maxFileReceiveSizeMB"];
			}
			set
			{
				this["maxFileReceiveSizeMB"] = value;
			}
		}
			
	
		#region Colecciones
		
		[ConfigurationProperty("RequestHandlers", IsDefaultCollection = false)]
		[ConfigurationCollection(typeof(RequestHandlersCollection),
			AddItemName = "add",
			ClearItemsName = "clear",
			RemoveItemName = "remove")]
		public RequestHandlersCollection RequestHandlers
		{
			get
			{
				RequestHandlersCollection urlsCollection =
					(RequestHandlersCollection) base ["RequestHandlers"];
				return urlsCollection;
			}
		}
		
		#endregion
	}
}
